package Meituan;

import java.lang.ref.SoftReference;
import java.lang.ref.WeakReference;

/**
 * @author: leiwenkang02@meituan.com
 * @date: 2019/3/18
 * @time: 20:20
 */
public class WeakReferenceTest {
    public static void main(String[] args) {
        WeakReference<String> weakReference = new WeakReference<String>(new String("abc"));
//        SoftReference<String> weakReference = new SoftReference<>(new String("abc"));
        System.gc();
        System.out.println(weakReference.get());

//        if(weakReference.get() == null) {
//            System.out.println("weakReference已经被GC回收");
//        }
    }
}
